<template>
	<view class="button-sp-area">
		<button class="bottom" type="primary" @tap="bindGetUserInfo">点击跳转</button>
		<private_tip :privateShow="privateb"></private_tip>
		<!-- <button class='bottom' type='primary' bindtap="openChannelsLive">
    打开视频号
  </button> -->
	</view>
</template>

<script>
	//获取应用实例
	const app = getApp();
	export default {
		data() {
			return {
				privateb:false,
			};
		},
		onLoad: function(options) {
			let _this=this;
			if(app.globalData.wxprivate==-1){
				app.watchG('wxprivate',function(value){
					_this.wxprivate=value;
					if(value){ //弹出弹窗
						_this.privateb=true;
					}else{
						_this.onload(options);
					}
				})
			}else{
				if (app.globalData.wxprivate) { //弹出弹窗
					_this.privateb = true;
				} else {
					_this.onload(options);
				}
			}
		},
		methods: {
			onload(options){
				if (options && options.appid) {
					var data = options.appid.split('||');
				} else {
					var data = [];
				}
				this._appid = data[0];
				if (data.length > 1) {
					this._url = data[1];
				}
			},
			bindGetUserInfo: function(e) {
				var _appid = this._appid;
				var _path = this._url;
				if (_path && _path.indexOf('huoniao/') > -1) {
					_path = _path.replace('huoniao/', '/pages/redirect/index?url=/');
				}
				_path = _path == '' ? '' : _path;
				uni.navigateToMiniProgram({
					appId: _appid,
					path: _path,
					success(res) {
						uni.navigateBack();
					},
					fail(res) {
						uni.showToast({
							title: res,
							icon: 'success',
							duration: 2000
						});
					}
				});
			},

			openChannelsLive: function() {
				uni.openChannelsUserProfile({
					finderUserName: 'sphW17ETAozle4I'
				});
			}
		}
	};
</script>
<style>
	@import './openxcx.css';
</style>